Many game programmers claim that you should not process events at all, not even with GetOSEvent, because it is too slow. Others claim that you should always use WaitNextEvent no matter what.
I say that both are wrong. GetOSEvent is very fast. WaitNextEvent is not, not even when quitting all other applications except Finder, and quitting the Finder is no good habit IMHO. Reading the keyboard with GetKeys is fast, but hopelessly incompatible with other keyboard layouts than your own. There is a workaround, but few use it.
This application is an experiment, to find out the truth. You can select any of four methods, GetNextEvent, WaitNextEvent( with a sleep time of zero), GetOSEvent and None (which uses Button and GetKeys).
In my experiments, GetOSEvent had no significant disadvantage to Button/GetKeys. Here are some measurements (with only Finder running at the same time when measuring GNE and WNE):
PowerMac 6100/60, native:
GetNextEvent: 305 loops/s
WaitNextEvent: 295 loops/s
GetOSEvent: 32200 loops/s
None: 30400 loops/s
PowerMac 6100/60, emulated:
GetNextEvent: 285 loops/s
WaitNextEvent: 270 loops/s
GetOSEvent: 53200 loops/s
None: 154000 loops/s
Performa 630:
GetNextEvent: 470 loops/s
WaitNextEvent: 450 loops/s
GetOSEvent: 40200 loops/s
None: 64000 loops/s
The whopping speed under emulation on the PowerMac - much higher than native! - is obviously caused by calling a lot of emulated code, so the native code spends almost as much time in emulation as the emulated one, but must also cope with context switches.
I conclude that both GetOSEvent and Button/GetKeys are so fast that we can use them without fear of any slowdown. GetOSEvent is usually the better of the two since it is much easier to stay compatible with different keyboard layouts. GetNextEvent and WaitNextEvent are fine as long as you don't have any background processes running, but 300 loops per second means that they take a not entirely insignificant processing time. If you aim for 60 fps, they eat 1/5 of your total processing power, while the faster methods only eat 1%.
Feel free to draw your own conclusions, and to hunt down any mistakes I may have made. This was a quick hack, and sure I may have overlooked something – but I doubt it.